"""add user role column

Revision ID: 20251031_add_user_role
Revises: 728e7afdb1a2
Create Date: 2025-10-31

"""
from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = '20251031_add_user_role'
down_revision = '728e7afdb1a2'  # 上一个迁移的 revision ID
branch_labels = None
depends_on = None


def upgrade():
    """添加用户角色字段"""
    # 添加 role 字段
    op.add_column(
        'users',
        sa.Column('role', sa.String(20), nullable=False, server_default='user', comment='用户角色')
    )
    
    print("✅ 已添加 users.role 字段")


def downgrade():
    """移除用户角色字段"""
    # 删除 role 字段
    op.drop_column('users', 'role')
    
    print("✅ 已删除 users.role 字段")

